<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
 <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
	<head>
		<meta name="decorator" content="center_common" />
		<script type="text/javascript">
	
		  function chooseStore(){
			  var st=$("#store").val();
			  var pp=$("#ppType").val();
			  if(st.length>0&&pp.length>0){
				
				  $(".submit_btn").removeAttr("disabled");
				  $(".submit_btn").removeAttr("style");
				  
			  }else{
				
				  $(".submit_btn").attr("disabled", 'disabled');
				  $(".submit_btn").css("background", '#333');
			  }
		  }
		  
		 
		
		  function ppTypeChange(){
			  var st=$("#store").val();
			  var pp=$("#ppType").val();
			  if(st.length>0&&pp.length>0){
				  $(".matchType").val(pp);
				  $(".submit_btn").removeAttr("disabled");
				  $(".submit_btn").removeAttr("style");
				  
			  }else{
				
				  $(".submit_btn").attr("disabled", 'disabled');
				  $(".submit_btn").css("background", '#333');
			  }
			  
			  
			  
		  }
		 function importOrder(){
			 $("#storeCode").val($("#store").val());
			 $("#del_tk").show();
		 }
		 
		 function cancle(){
			 $("#del_tk").hide();
		 }
		 
		  function submitOrder(){
			  //var file=$("#uploadFile").files;
			  
			  var file=document.getElementById("uploadFile").files;
			  if(file.length>0){
			  $("#forms").submit();
			  $("#del_tk").hide();
			  }
			 
		 } 
		 
		  $(function(){
			  var useNum=$("#useNum").val();
			  if(useNum<1){
				  $("#nexStep ").removeAttr('href');
			  }else{
				$("#nexStep").removeAttr("style");
			    $("#nexStep").removeAttr("disabled");
			  }
			  var ords=$("#ords").val();
			  if(ords.length>0){
				  $(".our_adress_table").show();
				  $("#yzta").show();
			  }
		  })
		  
		  function dele(v){
		  $("#goodsName").val(v);
			 $("#formss").submit();
		  }
		  
		  function chooseStatus(){
			  $("#status").val($("#chooStatus").val());  
			  $("#formss").submit();
		  }
		  
		  $(function(){
			  var storeCode=$("#codes").val();
			    
			       if(storeCode.length>0){
				   $("#store option").each(function () {
					   if($(this).val()==storeCode){
						   $(this).attr("selected","selected")
						   $(".submit_btn").removeAttr("disabled");
						   $(".submit_btn").removeAttr("style");
					   }
					   
					})
			       }
				var status=$("#status").val();
				$("#chooStatus option").each(function(){
					 if($(this).val()==status){
						 $(this).attr("selected","selected")
					 }
					
				}) 
				
				var stg=$("#mess").val();
				if(stg==1){
					$('#checkShowBoxSpan').text('请选择正确的模板!');
			   		$('#checkShowBox').show();
				}
				
			  })
			  
		 
		  
		</script>
	</head>
	<body>
		<!--头部-->
	
	<!--头部结束-->
	<!--导航-->
	<!--导航结束-->
	<!--4line-->
	
	<input value="${mess }" id="mess" type="hidden">
	<!--4line结束-->
	<!--主题内容-->
	<form action="${ctxWeb}/order/selectFastOrder" method="post" id="formss">
	<input name="goodsName" id="goodsName" type="hidden">
	<input name="status" id="status" value="${status }" type="hidden"/>
	<input id="ords" value="${ords }" type="hidden" />
	<input name="failureNum" value="${failureNum }" type="hidden"/>
	<input name="orderLength" value="${orderLength }" type="hidden"/>
	<input value="${storeCode }" id="codes" name="storeCode" type="hidden"/>
	</form>
	<input type="hidden" value="${orderLength-failureNum}" id="useNum">
	<div class="parts_main_box bgf5">
		<div class="container">
			<div class="row">
				<!-- pc 订单管理 -->
				<div class="Credit_box clearfix">
					
					<!-- 左边部分 end-->
					<!-- 右边部分 -->
					<div class="col-sm-10 pad20 pad_10">
						<div class="Credit_right">
							<!--快速下单-->
							<div class="goods_detail_info_box mar_16 clearfix">
								<h3>
									<span>
										快速下单
										<strong class="hover_tips">
											<em class="tips_yellow">(说明)</em>
											<b style="z-index:1">快速下单可在指定门店进行批量快速下单，若存在匹配失败的信息，无法进行下一步操作，可导出错误信息，修改后重新上传</b>
										</strong>
										
									</span>
									<a href="${ctxWeb}/order/importFastOrder" class="loading_demo" >下载模板</a>
								</h3>
								<div class="loading_info_box">
									<div class="form-group clearfix" style="margin-bottom:10px;">
									    <label  class="input_info control-label">
									    	选择门店：
									    </label>
									    <div class="col-sm-9 col-xs-8 input_left">
									      	<select  class="form-control hy" id="store" onchange="chooseStore()" name="stoName">
										       <option value="">请选择门店</option>
										      <c:forEach var="fastStore" items="${fastStore }">
										      <option value="${fastStore.code }">${fastStore.cnName }</option>
										      </c:forEach>
										    </select>
										   
										    
									    </div>
									    
									</div>
									
									
										<div class="form-group clearfix">
									    <label  class="input_info control-label">
									    	匹配方式：
									    </label>
									    <div class="col-sm-9 col-xs-8 input_left">
										      <select  class="form-control hy" id="ppType" onchange="ppTypeChange()">
										    
										        <option value="0">配件编号</option>
										        <option value="1">厂家编号</option>
										        <option value="2">物料编号</option>
										    </select>
										    <button class="submit_btn" disabled="disabled" onclick="importOrder()" style="background: #333">上传</button>
									    </div>
									    
									</div>
								</div>
								<!--快速下单表格-->
								<div class="our_adress_box qucliy_order">
									<!--验证结果-->
									<div class="vel_result clearfix" style="display:none" id="yzta">
										<figure class="col-sm-6 vel_result_left pad0">
											验证结果（
											<span>成功${orderLength-failureNum}条     失败${failureNum }条    总数${orderLength}条</span>）
										</figure>
										<figure class="col-sm-6 vel_result_right pad0 clearfix">
											<div class="export_btn">
												<a href="${ctxWeb}/order/exportOrders">导出</a>
											</div>
											 <div class="form-group clearfix">
											    <label>
											    	状态:
											    </label>
											    <div class="vel_result_right_info">
											      	<select  class="form-control hy" onchange="chooseStatus()" id="chooStatus">
												      <option value="">请选择</option>
												      <option value="0">成功</option>
												      <option value="1">失败</option>
												    </select>
											    </div>
											</div>
											
										</figure>
									</div>
									<!--验证结果结束-->
									<div class="our_adress_table  clearfix" style="display:none">
										<table class="table table-bordered">
										    <thead>
											    <tr>
											        <th>商品名称</th>
											        
											        <th>
											     
											           ${ppTitle}
										
											   
											      
											     </th>
											   
											        <th>价格</th>
											        <th>数量</th>
											        <th>状态说明</th>
											        <th>操作</th>
											    </tr>
										    </thead>
										    <tbody>
										       <c:forEach var="list" items="${list }" varStatus="status">
											    <tr>
											        <td>${list.cnName }</td>
											         <td> 
											         <c:if test="${list.stu=='0'}"> 
											     
											         <c:if test="${list.partsCode!=null }">${list.partsCode } 
											              </c:if>
											            <c:if test="${list.partsCode==null }">
											          
											            </c:if>
											           
											          
								                      </c:if>
								                       
								                       <c:if test="${list.stu=='1'}"> 
											     
											          <c:if test="${list.venderCode!=null }">${list.venderCode } 
											              </c:if>
											            <c:if test="${list.venderCode==null }">
											          
											            </c:if>
											           
											          
								                      </c:if>
								                      
								                       <c:if test="${list.stu=='2'}"> 
											     
											           <c:if test="${list.code!=null }">${list.code } 
											              </c:if>
											            <c:if test="${list.code==null }">

											            </c:if>
											           
											           
								                      </c:if>
								                  </td>
								                      
								                      
						
											       
											     
											     <td>
											        <c:if test="${list.failReason=='0' }">¥${list.price }
											       </c:if>
											        <c:if test="${list.failReason=='1' }">
											       </c:if>
											       </td>
											        
											        <td>${list.goodsNum }</td>
											         
											        <c:if test="${list.failReason=='0' }">
											        <td class="color_red col_gry js_set">成功</td>
											        </c:if>
											        <c:if test="${list.failReason!='0' }">
											        <td class="color_red color_red js_set">
											              <c:if test="${list.failReason=='1' }">
											                                                   编号匹配失败
											              </c:if> 
											               <c:if test="${list.failReason=='2'}" >
											                                                   商品名称匹配失败
											              </c:if>
											               <c:if test="${list.failReason=='3'}" >
											                                                   商品名称与编号不一致匹配失败
											              </c:if>
											        </td>
											        </c:if>
											         
											        <td class="color_blue">
											           <%-- <c:if test="${list.failReason!='0' }"> --%>
											        	<a href="javascript:void(0)" class="js_del" onclick="dele('${list.cnName}')">删除</a> 
											        <%-- 	</c:if>   --%>
											        </td>
											    </tr>
											    </c:forEach>
											    <!-- <tr>
											        <td>范范范</td>
											        <td>15101095083225</td>
											        <td>¥3232.00</td>
											        <td>2</td>
											        <td class="color_red color_red js_set">商品名称匹配失败</td>
											        <td class="color_blue">
											        	<a href="javascript:void(0)" class="js_del">删除</a>   
											        </td>
											    </tr>
											    <tr>
											        <td>范范范</td>
											        <td>15101095083225</td>
											        <td>¥3232.00</td>
											        <td>1</td>
											        <td class="color_red color_red js_set">商品名称匹配失败</td>
											        <td class="color_blue">
											        	<a href="javascript:void(0)" class="js_del">删除</a>   
											        </td>
											    </tr> -->
										    </tbody>
										</table>
										<a href="${ctxWeb}/shoppingCart/quickOrder?storeCode=${storeCode}" class="next_btn" id="nexStep" style="background:#333">下一步</a>
									</div>
								</div>
								<!--快速下单表格结束-->
							</div>	
							<!--快速下单结束-->
							
						</div>
					</div>
					<!-- 右边部分 end-->
				</div>
				<!-- pc 订单管理 end -->
			</div>
		</div>
	</div>
	<!--主题内容-->
	<!--foot-->
	
	<!--新增修改地址弹框结束-->
	<!--弹框-->
		<div class="jd_tk" id="del_tk" style="display: none;">
		    <div class="delet_box">
		        <form  id="forms" enctype="multipart/form-data" method="post" action="${ctxWeb}/order/uploadOrder">
		        <input id="uploadFile" name="file" type="file" style="width:260px;border: none;" />
		        <input id="storeCode" name="storeCode" type="hidden"/>
		        <input name="ppType" type="hidden" class="matchType">
		       </form>  
		        <div class="jd_btn clearfix">
		            <a href="javascript:void(0)" class="cancle" onclick="cancle()">取消</a>
		            <a href="javascript:void(0)" class="submit" onclick="submitOrder()">确定</a>
		        </div>
		
		    </div>
		</div>
	<!--弹框结束-->
	</body>
	
</html>
